package ${g.codePackage}.service;
import  ${g.codePackage}.res.Response;
import ${g.codePackage}.req.QueryPage;
import ${g.codePackage}.dao.curd.${t.entityName}DaoCrud;
import ${g.codePackage}.entity.${t.entityName};
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;

@Service
public class ${t.entityName}Service extends BaseService {

    @Autowired
    private ${t.entityName}DaoCrud ${t.prefixTableName}DaoCrud;

    /**
    *
    * 添加${t.tableComment}
    */
    public Response add${t.entityName}(${t.entityName} ${t.prefixTableName}){
        ${t.prefixTableName}DaoCrud.save(${t.prefixTableName});
        return  Response.success("添加成功");
    }

    /**
    *
    * 删除${t.tableComment}
    */
    public Response remove${t.entityName}ByIds(String ids){
        ${t.prefixTableName}DaoCrud.removeByIds(Arrays.asList(ids.split(",")));
        return  Response.success("删除成功");
    }

    /**
    *
    * 修改${t.tableComment}
    */
    public Response update${t.entityName}ById(${t.entityName} ${t.prefixTableName}){
        ${t.prefixTableName}DaoCrud.updateById(${t.prefixTableName});
        return  Response.success("修改成功");
    }

    /**
    *
    * 根据id查询
    */
    public Response find${t.entityName}ById(String id){
        ${t.entityName} ${t.prefixTableName}= ${t.prefixTableName}DaoCrud.getById(id);
        return  Response.success(${t.prefixTableName});
    }

    /**
    *  列表分页查询
    */
    public Response find${t.entityName}Page(QueryPage data){
        IPage<${t.entityName}> page=new Page<>(data.getPageNum(),data.getPageSize());
        QueryWrapper<${t.entityName}> queryWrapper=new QueryWrapper<>();
        IPage<${t.entityName}> pageInfo = ${t.prefixTableName}DaoCrud.page(page, queryWrapper);
        return Response.success(pageInfo.getRecords(),pageInfo.getTotal());
    }

}

